package com.solomiao.demo.multi.thread.demo9;

import java.util.function.Supplier;

/**
 * @desc 实现Supplier接口，定义异步任务的返回值
 *
 */
public class SupplierDemo9 implements Supplier<Long> {
    @Override
    public Long get() {
        System.out.println("正在执行，线程：" + Thread.currentThread().getName());
        try {
            // 模拟任务执行耗时
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            System.out.println("任务 " + Thread.currentThread().getName() + " 被中断");
        }
        return System.currentTimeMillis();
    }
}
